﻿Imports DataAccess
Imports Entities

Public Class ChoferBL
    Public Shared Function List() As List(Of CHOFERES)
        Dim lista As New List(Of CHOFERES)
        lista = ChoferDAL.List
        If lista.Count > 0 Then
            Return lista
        Else
            Return Nothing
        End If
    End Function
    Public Shared Function Save(ByVal zObject As CHOFERES) As Boolean
        If ChoferDAL.Exist(zObject.RUT) Then
            ChoferDAL.Update(zObject)
            Return True
        Else
            Return ChoferDAL.Create(zObject)
        End If
    End Function

    Public Shared Function Delete(ByVal zId As String) As Boolean
        Return ChoferDAL.Delete(zId)
    End Function

    Public Shared Function SearchById(ByVal zId As String) As CHOFERES
        Dim obj As New CHOFERES
        obj = ChoferDAL.SearchByRut(zId)
        If Not IsNothing(obj) Then
            Return obj
        Else
            Return Nothing
        End If
    End Function


    Public Shared Function GetNombre(ByVal zId As String) As String
        Dim obj As New CHOFERES
        obj = ChoferDAL.SearchByRut(zId)
        If Not IsNothing(obj) Then
            Return obj.NOMBRES
        Else
            Return ""
        End If
    End Function
End Class
